GBML manual / Core

profile_percent

How much of one frame the last frame spent on this phase, as a percentage. 100 means one whole frame's worth of time.

Works differently on Game Boy - The Game Boy has no frame profiler: profile_enabled says false and every profile number reads 0.

Works differently on Game Boy Color - The Game Boy Color has no frame profiler: profile_enabled says false and every profile number reads 0.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

profile_percent(phase) -> real

Arguments

NameType
phaseint

Returns

real

Description

How much of one frame the last frame spent on a phase, as a percentage. 100 means exactly one frame's worth of time. So profile_percent(10) reading 12 means that phase used 12 out of every 100 frames' worth of time you have.

The GBA draws a new frame about 60 times a second, and each one has a fixed amount of time. If the game needs more than that, the frame is late and the game runs slow. So profile_percent(PROFILE_TOTAL) is the number to watch: under 100 is fine, over 100 means lag. The phases add up to the total.

One frame jumps around a lot. If you want something steady to read, use profile_average. If you want to catch a short spike, use profile_worst.

Example

var total = profile_percent(PROFILE_TOTAL);
if (total > 100) {
    draw_text(4, 4, "TOO SLOW");
}

Warns when the last frame took longer than a frame is allowed to.

Cost

Reading it costs one small division. With the profiler off it is the plain value 0.

On the GBA

Add up all the phases and you get PROFILE_TOTAL. If the total goes over 100, the frame took longer than the screen allows and the game runs slow. A bad phase number reads 0, and so does everything when the profiler is off. A single frame jumps around a lot; profile_average is easier to read.

See also: profile_averageprofile_worstprofile_cyclesPROFILE_TOTAL